<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>The &lt;daoGenerator&gt; Element</title>
  <link type="text/css" rel="stylesheet" href="../ibator.css"/>
</head>
<body>

<div class="menuNav">
  <p>
    <a href="../index.html" target="_top">Show Menu</a>
    <a href="daoGenerator.html" target="_top">Hide Menu</a>
  </p>
</div>

<h1>The &lt;daoGenerator&gt; Element</h1>
<p>The &lt;daoGenerator&gt; element is used to define properties of the DAO
generator.  The DAO Generator builds DAOs in a variety of different formats - one
DAO interface and implementation class for each
introspected table. This element is a optional child element
of the <a href="ibatorContext.html">&lt;ibatorContext&gt;</a> element.  If you do not
specify this element, then Ibator will not generate DAO interfaces and classes.</p>
<h2>Required Attributes</h2>
<table border="1" cellspacing="0" cellpadding="5">
  <tr>
    <th>Attribute</th>
    <th>Description</th>
  </tr>
  <tr>
    <td valign="top">type</td>
    <td>This attribute is used to select one of the predefined DAO generators, or
        to specify a user provided DAO generator.
        Any user provided DAO generator must extend the class
        <code>org.apache.ibatis.ibator.generator.AbstractJavaGenerator</code>
        class, and must have a public default constructor.
        <p>The attribute accepts the following values for selecting one of the
        predefined DAO generators:</p>
        <table cellpadding="5">
          <tr>
            <td colspan="2">If the &lt;ibatorContext&gt; targetRuntime is <b>Ibatis3</b>:</td>
          <tr>
          <tr>
            <th nowrap="nowrap" valign="top">MAPPER</th>
            <td>The generated "DAO" objects will be Java interfaces to the iBATIS 3.x mapper infrastructure.</td>
          </tr>
          <tr>
            <td colspan="2">If the &lt;ibatorContext&gt; targetRuntime is <b>Ibatis2Java2</b>
              or <b>Ibatis2Java5</b>:</td>
          <tr>
          <tr>
            <th nowrap="nowrap" valign="top">IBATIS</th>
            <td>The generated DAO objects will conform to the (now deprecated) iBATIS DAO framework.</td>
          </tr>
          <tr>
            <th nowrap="nowrap" valign="top">GENERIC-CI</th>
            <td>The generated DAO objects will rely only on the SqlMapClient.  The SqlMapClient
                will be supplied by constructor dependency injection.
            </td>
          </tr>
          <tr>
            <th nowrap="nowrap" valign="top">GENERIC-SI</th>
            <td>The generated DAO objects will rely only on the SqlMapClient.  The SqlMapClient
                will be supplied by setter dependency injection.
            </td>
          </tr>
          <tr>
            <th nowrap="nowrap" valign="top">SPRING</th>
            <td>The generated DAO objects will conform to the Spring DAO framework.</td>
          </tr>
        </table>
    </td>
  </tr>
  <tr>
    <td valign="top">targetPackage</td>
    <td>This is the package where the generated DAO interfaces and implementation classes
        will be placed.  In
        the default generators, the property "enableSubPackages"
        controls how the actual package is calculated.  If true,
        then the calculated package will be the targetPackage plus
        sub packages for the table's catalog and schema if they exist.
        If "enableSubPackages" is false (the default) then the calculated package will be
        exactly what is specified in the targetPackage attribute.
        Ibator will create folders as required for the generated
        packages.
        <p><b>Note:</b> the package for DAO implementation classes may
        be overridden by specifying the optional <code>implementationPackage</code>
        attribute as shown below.</p></td>
  </tr>
  <tr>
    <td valign="top">targetProject</td>
    <td>This is used to specify a target project for the
        generated DAO interfaces and classes.  When running in the Eclipse
        environment, this specifies the project and source folder where
        the objects will be saved.
        In other environments, this value should be an existing directory
        on the local file system.  Ibator will not create this directory if
        it does not exist.</td>
  </tr>
</table>

<h2>Optional Attributes</h2>
<table border="1" cellspacing="0" cellpadding="5">
  <tr>
    <th>Attribute</th>
    <th>Description</th>
  </tr>
  <tr>
    <td valign="top">implementationPackage</td>
    <td>If specified, DAO implementation classes will be placed in this package.
        In the default generators, the property "enableSubPackages"
        controls how the actual package is calculated.  If true,
        then the calculated package will be the implementationPackage plus
        sub packages for the table's catalog and schema if they exist.
        If "enableSubPackages" is false (the default) then the calculated package will be
        exactly what is specified in the implementationPackage attribute.
        Ibator will create folders as required for the generated
        packages.</td>
  </tr>
</table>

<h2>Child Elements</h2>
<ul>
  <li><a href="property.html">&lt;property&gt;</a> (0..N)</li>
</ul>

<h2>Supported Properties</h2>
<p>This table lists the properties of the default SQL Map generators that can be
specified with the <a href="property.html">&lt;property&gt;</a> child element:</p>
<table border="1" cellspacing="0" cellpadding="5">
  <tr>
    <th>Property Name</th>
    <th>Property Values</th>
  </tr>
  <tr>
    <td valign="top">enableSubPackages</td>
    <td>This property is used to select whether Ibator will generate different
        Java packages for the objects based on the catalog and schema of the
        introspected table.
        <p>For example, suppose a table MYTABLE in schema MYSCHMA.
        Also suppose that the targetPackage attribute is set to "com.mycompany".
        If this property is true, the generated DAO interface and class for the table
        will be placed in
        the package "com.mycompany.myschema".  If the property is false, the generated
        SQL Map will be placed in the "com.mycompany" schema.</p>
        <p><i>The default value is false.</i></p></td>
  </tr>
  <tr>
    <td valign="top">exampleMethodVisibility</td>
    <td>This property is used to set the visibility of the different "ByExample"
        methods - selectByExample, deleteByExample, etc.  If not specified, the
        methods will be public and will be declared in the DAO interface.
        This property allows you to hide these methods if you only want to use them
        to implement other specialized DAO methods.
        <table cellpadding="5">
          <tr>
            <th nowrap="nowrap" valign="top">public</th>
            <td><i>This is the default value</i><br/>
              The generated methods in the implementation class will be public,
              and the methods will be declared in the DAO interface.</td>
          </tr>
          <tr>
            <th nowrap="nowrap" valign="top">private</th>
            <td>The generated methods in the implementation class will be private,
                and the methods will not be declared in the DAO interface
            </td>
          </tr>
          <tr>
            <th nowrap="nowrap" valign="top">protected</th>
            <td>The generated methods in the implementation class will be protected,
                and the methods will not be declared in the DAO interface
            </td>
          </tr>
          <tr>
            <th nowrap="nowrap" valign="top">default</th>
            <td>The generated methods in the implementation class will have default
                (package) visibility,
                and the methods will not be declared in the DAO interface
            </td>
          </tr>
        </table>
    </td>
  </tr>
  <tr>
    <td valign="top">methodNameCalculator</td>
    <td>This property is used to select a method name calculator.  A method name
        calculator can be used to provide different names for the DAO methods.
        You can select one of the predefined values, or you can specify the
        fully qualified name of a class that implements the
        <code>org.apache.ibatis.ibator.api.DAOMethodNameCalculator</code> interface
        if neither of the supplied options are appropriate in your environment.
        <table cellpadding="5">
          <tr>
            <th nowrap="nowrap" valign="top">default</th>
            <td><i>This is the default value</i><br/>
              The generated methods names will be very simple ("insert",
              "updateByPrimaryKey", etc.)  This is the same behavior as earlier versions
              of Ibator.</td>
          </tr>
          <tr>
            <th nowrap="nowrap" valign="top">extended</th>
            <td>The generated method names will include the name of the domain object
              associated with the method ("insertWidget", "updateWidgetByPrimaryKey", etc.)
            </td>
          </tr>
        </table>
    </td>
  </tr>
  <tr>
    <td valign="top">rootInterface</td>
    <td>This property can be used to specify a super interface for all generated
      DAO interface objects.  This value may be overridden by specifying
      the <code>rootInterface</code> property on a Table configuration.
      <p><b>Important:</b> Ibator does not verify that the interface exists, or is a
       valid Java interface.</p>
      <p>If specified, the value of this property should be a fully qualified
       interface name (like com.mycompany.MyRootInterface).</p></td>
  </tr>
</table>

<h2>Example</h2>
<p>This element specifies that we always want to place generated DAO interfaces and
objects
in the "'test.model" package and that we want to use subpackages based on the
table schema and catalog.  It also specifies that we want the generated DAO
class to be compatible with the iBATIS DAO framework.</p>
<pre>
&lt;daoGenerator targetPackage="test.model"
     targetProject="\MyProject\src" type="IBATIS"&gt;
  &lt;property name="enableSubPackages" value="true" /&gt;
&lt;/daoGenerator&gt;
</pre>

</body>
</html>
